import { getUnreadStatus } from '@/api/login'

export default {
  state: {
    readStatus: {},
  },
  mutations: {
    READ_STATUS: (state, value) => {
      state.readStatus = value
    },
  },
  actions: {
    getMessageReadStatus({ commit }) {
      return new Promise((resolve, reject) => {
        getUnreadStatus()
          .then((res) => {
            commit('READ_STATUS', {
              alarmMessageRead: res.alarmMessageRead,
              billMessageRead: res.billMessageRead,
              hycMessageRead: res.hycMessageRead,
              timeCardOrMonthlyCardMessageRead:
                res.timeCardOrMonthlyCardMessageRead,
              shareFailMessageRead: res.shareFailMessageRead,
            })

            resolve()
          })
          .catch((err) => {
            reject(err)
          })
      })
    },
  },
}
